package com.ctgu.expresshelper.dao;

import com.ctgu.expresshelper.entity.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface OrderDao {
    //新增订单
    @Insert("insert into `order`(fromAddress,toAddress,status,userid,shopid) values(#{fromAddress},#{toAddress},#{status},#{userid},#{shopid})")
    void addOrder(Order order);

    //删除订单
    @Delete(" delete from `order` where id= #{id} ")
    void deleteOrder(long id);

    //根据用户id查找全部
    @Select("select * from `order` where userid= #{userid} ")
    List<Order> findAll(long userid);

    //根据用户id查找未完成
    @Select("select * from `order` where userid= #{userid} and status=0")
    List<Order> findPart(long userid);

}
